import 'dart:ui';

import 'package:flutter/material.dart';
import 'res/listData.dart';

class CardLayout extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("有点f麻烦"),
        ),
        body: LayoutDemo(),
      ),
    );
  }
}

class LayoutDemo extends StatelessWidget {
  List<Widget> getData() {
    List<Widget> mList = new List();
    for (var i = 0; i < mListData.length; i++) {
      mList.add(Card(
        margin: EdgeInsets.all(10),
        child: Column(
          children: <Widget>[
            AspectRatio(
              aspectRatio: 20 / 9,
              child: Image.network(
                mListData[i]["imageUrl"],
                fit: BoxFit.cover,
              ),
            ),
            ListTile(
              leading: CircleAvatar(
                  backgroundImage: NetworkImage(
                mListData[i]["imageUrl"],
              )),
              title: Text(
                mListData[i]["title"],
              ),
              subtitle: Text(
                mListData[i]["author"],
                overflow: TextOverflow.ellipsis,
              ),
            )
          ],
        ),
      ));
    }
    return mList;
  }

  @override
  Widget build(BuildContext context) {
    return ListView(children: this.getData());
  }
}
